package com.abc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.google.gson.Gson;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.model.perceptron.PerceptronLexicalAnalyzer;
import com.hankcs.hanlp.seg.Segment;
import com.hankcs.hanlp.seg.Viterbi.ViterbiSegment;
import com.hankcs.hanlp.seg.common.Term;
import com.hankcs.hanlp.tokenizer.NLPTokenizer;
import com.hankcs.hanlp.tokenizer.lexical.AbstractLexicalAnalyzer;

public class Test {
	
	public static void main(String[] args) {
		Segment seg = HanLP.newSegment()
        .enableAllNamedEntityRecognize(true).enableNameRecognize(true).enableTranslatedNameRecognize(true)
        .enableJapaneseNameRecognize(true).enablePlaceRecognize(true).enableOrganizationRecognize(true)
        .enablePartOfSpeechTagging(true).enableIndexMode(true)
		.enableNumberQuantifierRecognize(true)
        .enableCustomDictionary(true)
        .enableOffset(true);
		HanLP.Config.enableDebug();
//		List<Term> terms = NLPTokenizer.segment("快鹿高管");
//		System.out.println(terms);
		
		System.out.println(seg.seg("棉花现货价格"));
		//enableEnglishRecognize
	}

//	public static void main(String[] args) {
//		
//		Map<String, String> map = new HashMap<>();
//		map.put("word", "n");
//		map.put("pos", "p");
//		List<Map<String, String>> l1 = new ArrayList<>();
//		l1.add(map);
//		
//		List<Map<String, String>> l2 = new ArrayList<>();
//		l2.addAll(l1);
//		
//		for (Map<String, String> m : l2) {
//			m.put("pos", "n");
//		}
//		Gson gson = new Gson();
//		System.out.println(gson.toJson(l1));
//		System.out.println(gson.toJson(l2));
//		
//		/*NLPTokenizer.ANALYZER.enableIndexMode(false);
//
//		List<Term> termList = StandardTokenizer.segment("蓝思科技独董辞职");
//		for (Term term : termList) {
//			System.out.println(term.word);
//			//System.out.println(term.toString());
//		}*/
//		//AbstractLexicalAnalyzer analyzer = NLPTokenizer.ANALYZER;
//		//System.out.println(analyzer);
//		
//		Segment seg = HanLP.newSegment()
//                .enableAllNamedEntityRecognize(true).enableNameRecognize(true).enableTranslatedNameRecognize(true)
//                .enableJapaneseNameRecognize(true).enablePlaceRecognize(true).enableOrganizationRecognize(true)
//                .enablePartOfSpeechTagging(true).enableIndexMode(false)
//        		.enableNumberQuantifierRecognize(true)
//                .enableCustomDictionary(true)
//                .enableOffset(true);
//		System.out.println(seg.seg("10%"));
//		
//		//System.out.println(NLPTokenizer.segment("蓝思科技独董辞职"));
//		/*System.out.println(NLPTokenizer.segment("我新造一个词叫幻想乡你能识别并标注正确词性吗？"));
//		// 注意观察下面两个“希望”的词性、两个“晚霞”的词性
//		System.out.println(NLPTokenizer.analyze("我的希望是希望张晚霞的背影被晚霞映红").translateLabels());
//		System.out.println(NLPTokenizer.analyze("支援臺灣正體香港繁體：微软公司於1975年由比爾·蓋茲和保羅·艾倫創立。"));
//*/	
//	
//		/*algorithm=perceptron
//				enableIndexMode=true
//				enableNameRecognize=false
//				enableNumberQuantifierRecognize=false
//				enableCustomDictionary=true
//				enableCustomDictionaryForcing=true
//				enableTranslatedNameRecognize=false
//				enableJapaneseNameRecognize=false
//				enableOrganizationRecognize=false
//				enablePlaceRecognize=false
//				[蓝/a, 思科/ntc, 技独/n, 董辞职/nr]*/
//		//ViterbiSegment segment = (ViterbiSegment) HanLP.newSegment("viterbi");
//		//System.out.println(segment.seg("蓝思科技独董辞职"));
//		Segment segment = HanLP.newSegment("crf")
//				.enableIndexMode(true)
//				.enableNameRecognize(false)
//				.enableNumberQuantifierRecognize(false)
//				.enableCustomDictionary(true)
//				.enableCustomDictionaryForcing(false)
//				.enableTranslatedNameRecognize(false)
//				.enableJapaneseNameRecognize(false)
//				.enableOrganizationRecognize(false)
//				.enablePlaceRecognize(false);
//		//System.out.println(segment.seg("科大讯飞"));
//		/*System.out.println("algorithm="+perceptron.);
//        System.out.println("enableIndexMode="+enableIndexMode);
//        System.out.println("enableNameRecognize="+enableNameRecognize);
//        System.out.println("enableNumberQuantifierRecognize="+enableNumberQuantifierRecognize);
//        System.out.println("enableCustomDictionary="+enableCustomDictionary);
//        System.out.println("enableCustomDictionaryForcing="+enableCustomDictionaryForcing);
//        System.out.println("enableTranslatedNameRecognize="+enableTranslatedNameRecognize);
//        System.out.println("enableJapaneseNameRecognize="+enableJapaneseNameRecognize);
//        System.out.println("enableOrganizationRecognize="+enableOrganizationRecognize);
//        System.out.println("enablePlaceRecognize="+enablePlaceRecognize);*/
//		/*int count = 10;
//		CountDownLatch latch = new CountDownLatch(count);
//		ExecutorService es = Executors.newFixedThreadPool(count);
//		for (int i = 0; i < count; i++) {
//			es.execute(new Runnable() {
//				
//				@Override
//				public void run() {
//					System.out.println(segment.seg("鲶鱼"));
//					latch.countDown();
//					
//				}
//			});
//		}
//		
//		try {
//			latch.await();
//			es.shutdown();
//		} catch (InterruptedException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}*/
//		
//	}

}
